﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Dynamic;
using System.Data.SqlClient;
using System.Configuration;
using Model;
using System.Data;
using System.Data.OleDb;
namespace DAL
{

    public class AdminDAL
    {
        static string conStr = ConfigurationManager.AppSettings["ConnStr"] + System.Web.HttpContext.Current.Server.MapPath("~/") + ConfigurationManager.AppSettings["dbPath"] + ";";
        public AdminInfo FindOneById(int id)
        {

            return new AdminInfo();
        }

        public static AdminInfo Login(string name, string pwd)
        {
            OleDbConnection con = new OleDbConnection(conStr);
            string sql = "select * from [admin] where username='" + name + "' and userpwd='" + pwd + "'";
            OleDbDataReader dr = CommonDAL.ExecuteReader(con, sql);
            AdminInfo info = new AdminInfo();
            while (dr.Read())
            {
                info.id = DataConvert.ToInt(dr["id"]);
                info.username = DataConvert.ToString(dr["username"]);
                info.userpwd = DataConvert.ToString(dr["userpwd"]);
            }
            dr.Close();
            con.Close();
            return info;
            
        }
    }
}
